home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / me_cd25.zip / ME2MUTT.ZIP / ABBREV.MUT next >
Text File  |  1992-11-09  |  2KB  |  71 lines

  1.     ;; abbrev.mut : abbrevation mode
  2.     ;; C Durland 4/88    Public Domain
  3.     ;; Junk code
  4.  
  5. ;; Note: This is a very limited abbrev mode.
  6.  
  7.  
  8. (include spoint.mut)
  9.  
  10. (const abbrev-buffer "*ABBREVs*")
  11.  
  12. (defun
  13.   stuff-text  (array byte text 1) HIDDEN
  14.   {
  15.     (int n z) 
  16.     (for (n 0) (!= 0 (z (text n)))(+= n 1)(exe-key z))
  17.   }
  18.   lookup-abbrev (string name) HIDDEN
  19.   {
  20.     (bool s)
  21.  
  22.     (save-point)
  23.     (switch-to-buffer abbrev-buffer)(beginning-of-buffer)
  24.     (if (re-search-forward (concat '^' name ' ' ))
  25.       {    (looking-at '.*') (s TRUE) }
  26.       (s FALSE)
  27.     )
  28.     (restore-point)(msg "")
  29.     s
  30.   }
  31.   expand-abbrev
  32.   {
  33.     (bool s)
  34.     
  35.     (if (and (!= 1 (current-column))
  36.     { (previous-character)(s (looking-at '\w'))(next-character) s } )
  37.     {
  38.       (previous-word)
  39.       (if (and (looking-at '\w+')(lookup-abbrev (get-matched '&')))
  40.     { (cut-word)(stuff-text (get-matched '&')) }
  41.     (next-word)
  42.       )
  43.     })
  44.   }
  45.  
  46.   select-abbrev-file
  47.   {
  48.     (string abbrev-file)
  49.     (abbrev-file (ask "What abbrev file do you want to load? "))
  50.     (kill-buffer abbrev-buffer)(save-point)
  51.     (switch-to-buffer abbrev-buffer)(read-file abbrev-file)
  52.     (buffer-flags -1 BFGone)
  53.     (restore-point)
  54.   }
  55.   key-pressed-hook (int key)
  56.   {
  57.     (switch key
  58.       0x20 ()    ; space
  59.       0x2C ()    ; comma
  60.       0x14D ()    ; Return
  61.       0x21 ()    ; !
  62.       0x2E ()    ; period
  63.       0x3F ()    ; ?
  64.       default (done)    ; key does not trigger abbrev expansion
  65.     )
  66.     (exe-key 0x1031)    ; S-1
  67.   }
  68. )
  69.  
  70. (bind-local-key "expand-abbrev" "S-1")
  71.